package cn.buk.tms.dto;

import cn.buk.common.util.DecimalUtil;
import cn.buk.tms.entity.bill.BillInfo;
import cn.buk.tms.entity.bill.SettlementSheet;
import cn.buk.tms.common.dto.CustomerDto;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

/**
 * @author yfdai
 */
public class SettlementDto {
    private List<BillInfo> bills;

    public static SettlementDto createBySettlement(SettlementSheet ss) {
        SettlementDto dto = new SettlementDto();
        BeanUtils.copyProperties(ss, dto);

        if (ss.getCustomer() != null) {
            CustomerDto customerDto = CustomerDto.create(ss.getCustomer().getId(), ss.getCustomer().getVipName(), null);
            dto.setCustomer(customerDto);
        }

        return dto;
    }

    private int id;

    private int enterpriseId;

    private String settlementNo;

    private int customerType;

    private CustomerDto customer;

    private String name;

    private int paid;

    private double amount;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastUpdate;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getEnterpriseId() {
        return enterpriseId;
    }

    public void setEnterpriseId(int enterpriseId) {
        this.enterpriseId = enterpriseId;
    }

    public String getSettlementNo() {
        return settlementNo;
    }

    public void setSettlementNo(String settlementNo) {
        this.settlementNo = settlementNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPaid() {
        return paid;
    }

    public void setPaid(int paid) {
        this.paid = paid;
    }

    public double getAmount() {
        return DecimalUtil.keepScale2(amount);
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public CustomerDto getCustomer() {
        return customer;
    }

    public void setCustomer(CustomerDto customer) {
        this.customer = customer;
    }

    public void setBills(List<BillInfo> bills) {
        this.bills = bills;
    }

    public List<BillInfo> getBills() {
        return bills;
    }

    public int getCustomerType() {
        return customerType;
    }

    public void setCustomerType(int customerType) {
        this.customerType = customerType;
    }
}
